<?

if ($c = stack('name')) {

	$_id_component	= $DATA['components'][$c]['id'];			//	list id value
	$_id_data		= D_MB_DATA;			//	meta id value
	$_id_meta		= D_MB_META;			//	meta id value
	
	$_lang = context('lang');
	$_id = $_id_component;
	
	$mckey = "cpn.sections.$_id.$_lang";
	
//	if (MC && ($t = $GLOBALS['mc']->get(MC_PREFIX.".cpn.sections.$_id.$_lang"))) {

	if ($t = mc($mckey)) {
		$DATA['components'][$c]['data'] = $t;
	} else {		
	
	
		$_crit = "id_data=$_id_data AND id_parent=$_id_component AND ".dbAndL('attr', AA_VISIBLE);

		$s = array_extend( array('path' => 'sections', 'w' => 400, 'h' => 300, 'caption' => ''), $DATA['components'][$c]['settings']);

		$s['path'] = createdir(FP_UPLOAD_PATH.$s['path'].'/');
		$s['h'] = (int)$s['h'];
		$s['w'] = (int)$s['w'];

		$DATA['components'][$c]['data'] = array_mark_bounds( datafetch_array('db_list', array('table' => tb('data'), 'where' => $_crit,	'order' => 'id_index', 'index' => 'id' )));

		$t = datafetch_array('loadmeta', $_id_meta, 
			array('parent' => array_keys($DATA['components'][$c]['data']), 'assoc' => $_lang, 'getclob' => true, 'source' => true));

		foreach($t as $v)
			$DATA['components'][$c]['data'][$v['id_parent']][$v['name']] = $v['value'];

		foreach($DATA['components'][$c]['data'] as $k => $v) {
			$DATA['components'][$c]['data'][$k]['image'] = checkImage($s['path'], $k);
		}
			

		mcSet($mckey, $DATA['components'][$c]['data'], MC_EXPIRE - mt_rand(2*60, 7*60));

	}
	
	unstack();
}